//
//  HEIMCommentCell.m
//  HealthFamily
//
//  Created by 吴欧 on 2021/2/8.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HEIMCommentCell.h"

@interface HEIMCommentCell ()

@property(nonatomic, strong) UILabel *textLb;

@property(nonatomic, strong) UILabel *gotoBtn;

@end

@implementation HEIMCommentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
  
        [self initUI];
        [self makeGesture];
    }
    return self;
}

- (void)makeGesture {
    [super makeGesture];
    UITapGestureRecognizer *contentTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(contentClick)];
    [self.bubbleView addGestureRecognizer: contentTap];
}

- (void)contentClick {
    if ([self.delegate respondsToSelector:@selector(onTapMessage:)]) {
        [self.delegate onTapMessage: self.model.message];
    }
}

- (void)initUI {
    _textLb = [UILabel new];
    _textLb.text = @"您对团队的本次服务满意吗？";
    _textLb.font = DYFont(16);
    _textLb.numberOfLines = 0;
    _textLb.lineBreakMode = NSLineBreakByCharWrapping;
    [self.bubbleView addSubview: _textLb];
    
    _gotoBtn = [UILabel new];
    _gotoBtn.text = @"去评价 >>";
    _gotoBtn.font = DYFont(16);
    _gotoBtn.textColor = CNavBgColor;
    [self.bubbleView addSubview: _gotoBtn];

    [_textLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bubbleView).mas_offset(10);
        make.left.equalTo(self.bubbleView).mas_offset(10);
        make.right.equalTo(self.bubbleView).mas_offset(-10);
    }];
    
    [_gotoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_textLb.mas_bottom).mas_offset(5);
        make.left.equalTo(self.bubbleView).mas_offset(10);
        make.width.offset([_gotoBtn.text widthForFont:_gotoBtn.font] + 10);
        make.bottom.equalTo(self.bubbleView).mas_offset(-10);
    }];
}

- (void)configCellWithModel:(HEIMMessageModel *)model {
    _textLb.text = model.message.text;
    _textLb.textColor = model.warpTextColor;
 
    // 必须写
    [self refreshData:model];
}

@end
